version: '3.8'

services:
  db_cust:
    image: postgres
    volumes:
      - ./init-scripts:/docker-entrypoint-initdb.d
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: rootpwd
    networks:
      - minibanknet
    restart: on-failure:3

  app_customers:
    build: ./appCustomers
    environment:
      - DOTENV_PATH=/app/appCustomers/.env
    ports:
      - "8000:8000"
    depends_on:
      - db_cust
    networks:
      - minibanknet
    restart: on-failure:3
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health", "||", "exit 1"]
      interval: 30s
      timeout: 30s
      retries: 3

  app_accounts:
    build: ./appAccounts
    environment:
      - DOTENV_PATH=/app/appAccounts/.env
    ports:
      - "8080:8080"
    depends_on:
      - db_cust
      - app_customers
    networks:
      - minibanknet
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    restart: on-failure:5
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/accounts/health", "||", "exit 1"]
      interval: 30s
      timeout: 30s
      retries: 3

networks:
  minibanknet:
    driver: bridge